package com.cody.date160122;

import java.util.*;

/**
 * test the runtime difference of sub arraylist and create new
 * Created by cody on 16/1/22.
 */
public class Exercise3 {

    public static void main(String[] args) {
        Integer[] arr = {1,2,3,4,5,6,7,8,9,10};
        List<Integer> total = new ArrayList<Integer>();
        Collections.addAll(total,arr);
        long timeNow = new Date().getTime();
        List<Integer> l1 = new ArrayList<Integer>();
        Iterator<Integer> it = total.iterator();
        while (it.hasNext()) {
            Integer i = it.next();
            if (i % 2 == 0) {
                it.remove();
                l1.add(i);
            }
        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long timeEnd = new Date().getTime();
        System.out.println(timeEnd - timeNow);
        System.out.println(Arrays.toString(total.toArray()));
        System.out.println(Arrays.toString(l1.toArray()));
    }

}
